class eventEmit {
  constructor() {
    this.events = {};
  }
  subscribe(method, callback) {
    if (this.events[method]) {
      this.events[method].push(callback);
    } else {
      this.events[method] = [callback];
    }
  }
  publish(method, data) {
    if (this.events[method]) {
      for (let i = 0; i < this.events[method].length; i++) {
        this.events[method][i](data);
      }
    }
  }
  remove(method) {
    this.events[method] = null
  }
}

module.exports = {
  bus: new eventEmit(),
  eventEmit
};
